home *** CD-ROM | disk | FTP | other *** search
/ Zoom 2 / Zoom - Release 2 (1996)(Active Software)[!].iso / programming / amos / amossible / maths / variables.amos / variables.amosSourceCode
Encoding:
AMOS Source Code  |  1980-05-17  |  1.7 KB  |  37 lines

  1. '**************THE WORLD IS EVER-CHANGING-By Mark Wickson********************* 
  2. Rem Variables-They're the key to good programming-And alot of the examples on
  3. Rem this disk use them.
  4. Rem For a better definition of variables look at the on-disk document files. 
  5. Rem A variable is something that changes(It VARIES-Hence variable),in  
  6. Rem programming,alot of coordinates can be variables,and you can work out
  7. Rem complicated problems with them.If I had a coordinate,for example,it
  8. Rem start at 5(So lets imagine it was a Bobs horizontal coordinate in a
  9. Rem main loop of a game):  
  10. Rem Bob 1,5,100,1
  11. Rem But now I want to make the Bobs horizontal value change-I could write  
  12. Rem Bob 1,10,100,1 
  13. Rem but if I want to make the horizontal value change again,I'd have 
  14. Rem to write:
  15. Rem Bob 1,15,100,1 
  16. Rem As you can see,if I don't want to make its position change drastically 
  17. Rem in one step,I have to write alot of lines-Unless I use a variable. 
  18. Rem A variable must be given a name-In this case,we're manipulating the
  19. Rem X axis of a Bob,so why not call it "X"(You could call it almost anything)
  20. Rem-First we have to write its starting point,in this case we want it to 
  21. Rem start at 5:
  22. Rem X=5
  23. Rem Then wewrite inside our loop:
  24. Rem X=X+5
  25. Rem So every loop,"X" is increased by 5-Then we would substitute the 
  26. Rem horizontal coordinate for our variable:
  27. Rem Bob 1,X,100,1
  28. Rem So now the Bob is displayed at new positions easily. 
  29. Rem Anything that uses numbers(Or text) can be manipulated by variables. 
  30. Rem in this example,we print the latest value of the variable "X"-Each loop, 
  31. Rem we increase its value by one.
  32. Rem YOU'LL HAVE TO BREAK OUT OF THIS WHEN YOU GET BORED! 
  33. X=0
  34. Do 
  35. X=X+1
  36. Print At(0,0);X
  37. Loop